package com.atguigu.gmall.product;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.atguigu.gmall.model.product.SkuInfo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @Author: lx
 * @Time: 10:42
 * @Description:
 */
@SpringBootTest
@RunWith(SpringRunner.class) //SpringBoot单元测试
public class RedisTemplateDemo {

    @Autowired
    private RedisTemplate redisTemplate;

    @Test
    public void test(){


        //  小明  语文 100  数学 99 英语 88
        //  小张  语文 100  数学 99 英语 88
        redisTemplate.opsForZSet().add("小明","语文",100);
        redisTemplate.opsForZSet().add("小明","数学",99);
        redisTemplate.opsForZSet().add("小明","英语",88);


     /*   SkuInfo sk = new SkuInfo();
        sk.setId(111L);
        sk.setSkuName("好");
        //String json = JSON.toJSONString(sk);
        redisTemplate.opsForValue().set("hoho",sk);*/

  /*      Boolean aBoolean = redisTemplate.opsForValue().setIfAbsent("num", "9");
        System.out.println(aBoolean);//false  锁已经在了 未获取到锁
*/

    }
}
